<%@ page contentType="text/html;charset=utf-8"%>
<%@ page import="java.util.*" %>

<%
	String category = request.getParameter("category");
	if (category==null) category="";
	String p = request.getParameter("p");
	if (p==null) p="";
 %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>资讯文章 - 3DS DS 游戏 资讯 攻略 发售 下载</title>
<meta name="description" content="" />
<meta name="keywords" content="动作冒险 DSDOWN 3DS DS DSI GB GBA WII WIIU Nintendo 任天堂 游戏 攻略 发售 资讯 " />
<link href="style/list.css" rel="stylesheet" type="text/css" />
<style type="text/css">
</style></head>

<script src="script/functions.js" type="text/javascript"></script>
<script src="script/jQuery.js" type="text/javascript"></script>
<script type="text/javascript">

	var header_count = 2;
	var nullsearch = "搜索游戏,资讯,攻略";	
	
	$(document).ready(
		function()
		{
			$("#searchtext").keydown(
			function(e)
			{
				if(e.which==13) doSearch();
			}
			)
		}
	)
	
	$(document).click(
	function()
	{
		hideTip('#category_menu');
	});
	
	function showHeaderNav(target,menuname)
	{
		var left = $(target).offset().left;
		var top = $(target).offset().top;
		
		$(menuname).css("left", left - 1 + "px");
		$(menuname).css("top", top + 36 + "px");
		$(menuname).css("display", "inline");
		$(target).attr("class", "inlineli header_nav_li_hover");
	}
	
	function showHeaderNavDelay(target,menuname)
	{
		var fun = "showHeaderNav('"+target+"','"+menuname+"');";
		setTimeout(fun,10);
	}
	
	function hideHeaderNav(target,menuname)
	{
		setTimeout(function()
			{
				$(menuname).css("display", "none");
				$(target).attr("class", "inlineli header_nav_li");
			},10);
	}
	
	function showTip(target,tipname)
	{
		var left = $(target).offset().left;
		var top = $(target).offset().top;
		var height = $(target).height();
		
		$(tipname).css("left",left + "px");
		$(tipname).css("top",top + height + "px");
		$(tipname).css("display","block");
	}
	
	function hideTip(tipname)
	{
		$(tipname).css("display","none");
	}
	
	function showMask(target)
	{
		var left = $(target).offset().left;
		var top = $(target).offset().top;
		var width = $(target).width();
		var height = $(target).height();
		
		$("#mask").css("left",left+"px");
		$("#mask").css("top",top+"px");
		$("#mask").css("width",width+"px");
		$("#mask").css("height",height+"px");
		$("#mask").css("display","block");
	}
	
	function hideMask()
	{
		$("#mask").css("display","none");
	}
	
	function doSearch()
	{
		var value = $("#searchtext").val();
		if (value=='' || value == nullsearch)
		{
			alert('请输入关键字');
			$("#searchtext").focus();
		}
		else if (value.length < 3)
		{
			alert('关键字太短，无法搜索');
			$("#searchtext").focus();
			$("#searchtext").select();
		}
		else
		{
			var uri = 'search.do?k='+ encodeURI(encodeURI(value));
			window.open(uri);
		}
	}
</script>



<body>
<!-- 外层 -->
<div class="detail">

<!-- 主页面 -->
<div class="main">

	<%@ include file="header.jsp" %>
	
	<div class="header_shadow"></div>
	
	<!-- 外框阴影 -->
	<div class="center_shadow">
		<!-- 内容 -->
		<div class="content">
      	<!-- 左侧栏 -->
      	<div class="leftdiv">
      	
      		<div class="filter">
				<div>
					<span>分类：</span>
					<% 	List<java.util.Map> articleTypeList = (List<java.util.Map>)request.getAttribute("articleTypeList");
						for (int i=0;i<articleTypeList.size();i++){
						if (articleTypeList.get(i).get("article_type_id").toString().equals(category)){ %>
					<b><%= articleTypeList.get(i).get("article_type_name") %></b>
					<% }else{
						String url = String.format(
						"article_list.do?category=%s&p=%s",
						articleTypeList.get(i).get("article_type_id"),
						1);
					%>
					<a href="<%= url %>"><%= articleTypeList.get(i).get("article_type_name") %></a>					
					<% }} %>
				</div>
			</div>
		
			<% List<java.util.Map> articleList = (List<java.util.Map>)request.getAttribute("articleList"); %>
			<% for (int i=0;i<articleList.size();i++){ %>
		
			<a class="newsitem" href="articledetail.do?id=<%= articleList.get(i).get("article_id") %>" target="_blank">
				<div class="newsitem_left">
					<img src="<%= articleList.get(i).get("article_icon") %>"/>
				</div>
				<div class="newsitem_right">
					<big><%= articleList.get(i).get("article_name") %></big>
					<small><%= articleList.get(i).get("create_date") %> by <%= articleList.get(i).get("article_writer") %></small>
					<small>类型：<%= articleList.get(i).get("article_type_name") %></small>
					<p><%= articleList.get(i).get("article_description") %></p>
				</div>
			</a>
			
			<% } %>
				
			<!-- 页码 -->
			<%
				Integer pageCount = (Integer)request.getAttribute("pageCount");
				if (pageCount>1)
				{
					Integer ppage = 1;
					if (p!="") ppage = Integer.valueOf(p);
					Integer pageStart = ppage - 3;
					if (pageStart<1) pageStart=1;
					Integer pageEnd = ppage + 3;
					if (pageEnd>pageCount) pageEnd=pageCount;
				
					String purl = String.format(
						"article_list.do?category=%s&p=",
						category
						);
			%>

			<div class="page">
				<% if (pageStart>1){ %><a href="<%= purl+"1" %>">第一页</a> ...<%} %>
				<%
					for (Integer i=pageStart;i<=pageEnd;i++){
						if (i.equals(ppage)){
				%>
							<span><%= i.toString() %></span>				
				<%
						}else{
				%>
							<a href="<%= purl+i.toString() %>"><%= i.toString() %></a>				
				<%		}
					}
				%>
				<% if (pageEnd<pageCount){ %>... <a href="<%= purl+pageCount.toString() %>">最后一页</a><%} %>
				
			</div>
			<% } %>
			<!-- page -->
		</div>
		<!-- left -->
		
		<!-- 右侧栏 -->
      	<div class="rightdiv">			
			<!-- 搜索框  -->
      		<ul class="searchborder">
				<li class="inlineli">
					<input id="searchtext" type="text" class="searchinput" value="搜索游戏,资讯,攻略" onfocus="if(this.value==nullsearch){this.value='';this.style.color='#000000';}" onblur="if(this.value==''){this.value=nullsearch;this.style.color='#888888';}" />
				</li>
				<li class="inlineli">
			        <a href="javascript:doSearch();" title="搜索" ></a>
				</li>
				<% java.util.Map count = (java.util.Map)request.getAttribute("count"); %>
				<span>共<%= count.get("games") %>个游戏，<%= count.get("articles") %>篇资讯文章</span>
			</ul>
			<!-- search -->
		
		
			<!-- 分类 TOP 5 -->
			<div class="rightbox_top"></div>
			<div class="toplist rightbox_center">
				<h1>分类文章TOP 10</h1>
				<% List<java.util.Map> articleTop10 = (List<java.util.Map>)request.getAttribute("articleTop10"); %>
				<% for (int i=0;i<articleTop10.size();i++){ %>
					<a href="articledetail.do?id=<%= articleTop10.get(i).get("article_id") %>" title="<%= articleTop10.get(i).get("article_name") %>" target="_blank"><div class="toplist_icon" style="background-position:0px -<%= i*15 %>px;"></div><div class="toplist_text"><%= articleTop10.get(i).get("article_name") %></div></a>
				<% } %>
			</div>
			<div class="rightbox_bottom"></div>
			<script type="text/javascript">
				limitCharacterLength(".toplist>a div",24);
				limitCharacterLength(".newsitem_right>big",38);
				limitCharacterLength(".newsitem_right>p",200);
			</script>
		</div>
		<!-- right -->	
		
		
		</div>
		<!-- 内容 -->
	</div>
	<!-- 外框阴影 -->
	
	<div class="footer_shadow"></div>	
	
	<!-- 页脚 -->
	<%@ include file="footer.jsp" %>
	
</div>
<!-- 主页面 -->
</div>
<!-- 外层 -->

</body>
</html>
